import request from "@/router/axios";
import {exportFunc} from "@/api/export";
// 查询
export const getList = params => {
  return request({
    url: "/api/hg-quality/inspectlist/page",
    method: "get",
    params
  });
};
// 根据物料编码和质检类型获取质检规则
export const getRule = params => {
  return request({
    url: "/api/hg-quality/rule/quality-rule-material/getRule",
    method: "get",
    params
  });
};
// 根据规则编码获取规则和规则项目
export const detailByRuleCode = params => {
  return request({
    url: "/api/hg-quality/rule/quality-rule/detailByRuleCode",
    method: "get",
    params
  });
};
// 详情
export const getDetail = params => {
  return request({
    url: "/api/hg-quality/inspectlist/detail",
    method: "get",
    params
  });
};
// 提交质检报告
export const startProcess = params => {
  return request({
    url: "/api/hg-quality/inspectlist/start-process",
    method: "post",
    params
  });
};
// 新增
export const save = data => {
  return request({
    url: "/api/hg-quality/inspectlist/save",
    method: "post",
    data
  });
};

// 修改
export const update = data => {
  return request({
    url: "/api/hg-quality/inspectlist/update",
    method: "post",
    data
  });
};

// 数据录入新增
export const inspectresultSave = data => {
  return request({
    url: "/api/hg-quality/inspectresult/save",
    method: "post",
    data
  });
};
// 修改详情
export const inspectlistDetail = params => {
  return request({
    url: "/api/hg-quality/inspectlist/detail",
    method: "get",
    params
  });
};

// 获取检查单号
export const getInspectId= params => {
  return request({
    url: "/api/hg-quality/inspectlist/generateInspectNo",
    method: "post",
    params
  });
};


// 根据产品ID和生产时间获取产品批次
export const getProBatchNoList = params => {
  return request({
    url: "/api/hg-quality/inspectlist/getBatchList",
    method: "get",
    params
  });
};
//来料检验检验统计
export const getCount = () => {
  return request({
    url: "/api/hg-quality/inspectlist/statistics",
    method: "get",
    params: {}
  });
};

export const getDictionary = type => {
  return request({
    url: "/api/blade-system/dict-biz/dictionary",
    method: "get",
    params: {
      code: type
    }
  });
};


// 查询
export const getRationList = ruleItemId=> {
  return request({
    url: "/api/hg-quality/inspectresult/list",
    method: "get",
    params:{
      ruleItemId:ruleItemId
    }
  });
};


// 删除
export const deleteInspection = ids => {
  return request({
    url: "/api/hg-quality/inspectlist/remove",
    method: "post",
    params:{
      ids: ids
    }
  });
};


export const getCheckProduct = materialNo => {
  return request({
    url: "/api/hg-public/prdinfo/list",
    method: "get",
    params: {
      materialNo
    }
  });
};

export const getProductList = params => {
  return request({
    url: "/api/blade-produce/product/productionreport/getReportListInfo",
    method: "get",
      params
  });
};


export const downloadFile = (params,headers) => {
  var strids = 'bucket_name=' + params.bucket_name + '&filePath=' + params.filePath
  exportFunc('/blade-system/attach/downloadFile', headers, strids, params.originalFilename)
}

